<template>
  <div>
    <van-nav-bar
      title="个人中心"
      :fixed="true"
    />
    <!--头像-->
    <div>
      <van-card
        desc="企业描述信息"
        title="南京智慧科技有限公司"
        thumb="https://img.yzcdn.cn/vant/apple-2.jpg"
      />
    </div>
    <div style="height: 500px;">
      <van-cell-group>
<!--        <van-cell title="用户头像" value="内容">

          <div style=" width:5rem;height:5rem;margin-left: 50%">
            &lt;!&ndash;  <van-image
                round
                width="5rem"
                height="5rem"
                src="https://img.yzcdn.cn/vant/cat.jpeg"
              />&ndash;&gt;
            <van-uploader v-model="fileList" multiple
                          :max-count="1"
            />
          </div>-->

          <!--userId: (...)
deptId: 1
email: null
nickName: "admin"
phonenumber: (...)
sex: (...)
address: (...)
enabled: (...)
username: (...)
password: (...)
status: (...)
delFlag: (...)
remark: (...)
dept: (...)-->
        <van-cell title="姓名" value="null" >
        {{data.nickName}}
        </van-cell>
        <van-cell title="电话" value="null">
          {{data.phonenumber}}
        </van-cell>
        <van-cell title="邮箱" value="null">
          {{data.email}}
        </van-cell>
        <van-cell title="性别" value="null">
          <span v-if="data.sex ==='1'">男</span>
          <span v-if="data.sex ==='2'">女</span>
        </van-cell>
        <van-cell title="所在部门" value="null">
          {{data.dept.deptName}}
        </van-cell>
        <van-cell title="部门主管" value="null">
          {{data.dept.leader}}
        </van-cell>


      </van-cell-group>
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit" @click="loginOut">
          退出
        </van-button>
      </div>

    </div>

  </div>
</template>

<script>
  import user from '@/api/user'

  export default {
    name: "index",
    data() {
      return {
        fileList: [
          // Uploader 根据文件后缀来判断是否为图片文件
          // 如果图片 URL 中不包含类型信息，可以添加 isImage 标记来声明
          {url: 'https://img.yzcdn.cn/vant/cat.jpeg', isImage: true}
        ],
        data: ''
      }
    },
    created() {
      this.getDetail();
    },
    methods: {
      //获取详情
      getDetail() {
        user.getUserInfoById({
          userId: this.$store.getters.userInfo.userId,
        })
          .then(res => {
            console.log(res);
            // 返回数据
            this.data = res;
          })
          .catch(err => {
            // 异常情况
          })
      },
      //退出登录
      loginOut() {
        this.$store.dispatch('logout').then(() => {
          this.loginIn()
        })

      },
      loginIn() {
        this.$router.push('/')
      },
      changeImg() {
        console.log("aa");
      }
    }
  }
</script>

<style scoped>

</style>
